import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;

public class Main {

    public static void main(String[] args) {
        try {
            String path;
            path=HomeDir.get(HomeDir.Folder.DOCUMENTS);
            path+="\\Humble Library.html";
            File input = new File(path);
            Document doc = Jsoup.parse(input, "UTF-8", "https://www.humblebundle.com/home");

            Elements elements = doc.select("div#regular_download_list");
            assert elements.size()==1;

            processDownloads(elements.first());
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }

    static private void processDownloads(Element downloads) throws Exception {
        Elements rows = downloads.getElementsByClass("row");
        for (Element row : rows) {
            HumbleDir dir=new HumbleDir(row);
            dir.download();
        }
    }
}
